import { ExportedResourceLibProps } from "@/components/ResourceLib"
import { ArticleObject } from "@/services"
import SSE from "@/Sse"

export interface UserInfo {
  [key: string]: any
}
export enum TAppType {
  MUSIC,
}
export type TApps = {
  [key in keyof typeof TAppType]: TAppItem
}
export interface TAppItem {
  status: "success" | "error" | "default" | "processing" | "warning" //app运行状态
  actived?: boolean //是否激活
  icon?: any
  name?: any
}
export interface MiniAppConfig {
  currentApp?: TAppType
}
export interface EditorContext {
  current: Record<string, any> & ArticleObject //当前正在编辑的文章
  curMemory: Record<string, any> & { id?: string } //当前正在更新的Memory
}
export interface AppSourceInfo {
  open?: boolean
  value?: any
  resourcesProps: ExportedResourceLibProps
}
export interface AppState {
  userInfo: UserInfo //用户信息
  editor: EditorContext //markdown编辑器
  myArticles: any[] //用户文章
  SSE?: SSE //sse
  apps: TApps //miniapp状态
  miniApp: MiniAppConfig
  appSource?: AppSourceInfo
}
export type Action =
  | "initUser" //初始化用户信息
  | "updateMyArticles" //更新文章列表
  | "updateCurrent" //更新当前编辑的文章信息
  | "updateContent" //更新文章内容
  | "updateMemory" //更新Memory内容
  | "initCurrent" //重置当前编辑的文章信息
  | "initMemory" //重置当前编辑的Memory信息
  | "updateMiniApp"
  | "updataAppSource"
  | "updateApps"

export interface EAction {
  type: Action
  payload: any
}
